<template>
	<view>
		<view class="container form-content">
			<uni-forms v-if="tabType === '0'" ref="form" :modelValue="formData" labelWidth="120px" labelPosition="top">
				<view class="container">
					<view class="hidden-title">基本信息</view>
					<view class="background-white">
						<view class="flex text">维护保养项目：
							<text>{{ detail.item }}</text>
						</view>
            <view class="flex text">维护保养内容：
              <text>{{ detail.content }}</text>
            </view>
            <view class="flex text">维护保养标准：
              <text>{{ detail.standard }}</text>
            </view>
            <view class="flex text">维护保养记录：
              <text>{{ detail.record }}</text>
            </view>
            <view class="flex text">维护保养牵头人：
              <text>{{ detail.userIdLabel }}</text>
            </view>
            <view class="flex text">维护保养参与人：
              <text>{{ detail.participantPerson }}</text>
            </view>
            <view class="flex text">实际维护保养时间：
              <text>{{ detail.completionTime }}</text>
            </view>
					</view>
				</view>
			</uni-forms>

      <uni-forms v-if="tabType === '1'" ref="form" :modelValue="formData">
        <view class="container">
          <view class="hidden-title">基本信息</view>
          <view class="background-white">
            <view class="flex text">维护保养项目：
              <text>{{ detail.item }}</text>
            </view>
            <view class="flex text">维护保养内容：
              <text>{{ detail.content }}</text>
            </view>
            <view class="flex text">维护保养标准：
              <text>{{ detail.standard }}</text>
            </view>
          </view>
        </view>
        <view class="maintenance-step">
          <view class="hidden-title">维护保养记录</view>
          <view class="">
            <view class="step-block" v-for="(d, di) in taskItemRespList" :key="di">
              <view class="step">
                <view class="step-no">{{di+1 > 9 ? di + 1 : '0' + Number(di+1)}}</view>
              </view>
              <view class="step-content background-white">
                <view class="content-item">
                  <text style="text-indent: 5px">维护保养记录：</text>
                  <text>{{d.record}}</text>
                </view>
                <view class="content-item">
                  <text style="text-indent: 5px">维护保养牵头人：</text>
                  <text>{{d.userIdLabel}}</text>
                </view>
                <view class="content-item">
                  <text style="text-indent: 5px">维护保养参与人：</text>
                  <text>{{d.participantPerson}}</text>
                </view>
                <view class="content-item">
                  <text style="text-indent: 5px">实际维护保养时间：</text>
                  <text>{{d.completionTime}}</text>
                </view>
                <view class="content-item">
                  <text style="text-indent: 5px">维护保养结果：</text>
                  <text>{{d.statusLabel}}</text>
                </view>
              </view>
            </view>
          </view>
        </view>
      </uni-forms>
    </view>
	</view>
</template>

<script>
  import {maintenanceRecord} from "../../../../api/equipment/maintenance";

	export default {
		data() {
			return {
				taskId: '',
        tabType: null,
        formData:{},
				detail: {
          item: '',
				},
        taskItemRespList: [],
			};
		},
		onLoad({
			taskId,
      info,
      tabType
		}) {
			this.taskId = taskId;
      Object.assign(this.detail, JSON.parse(info))
      this.setTitle(this.detail.item)
      // tabType 0: 待执行查看不调接口  1: 待确认查看调接口
      this.tabType = tabType
      console.log(typeof tabType)
      if (tabType === '1'){
        this.getDetail()
      }

		},
    onShow(){
    },
		onPullDownRefresh() {
      if (this.tabType === '1')
        this.getDetail();
		},
		methods: {
      setTitle(title) {
        uni.setNavigationBarTitle({
          title: title
        })
      },
			getDetail() {
        maintenanceRecord(this.taskId).then(res=>{
          this.taskItemRespList = res.rows
        })
			},
			navigateBack() {
				uni.navigateBack();
			}
		},
	};
</script>

<style lang="scss">
	.container {
    width: 96%;
    margin: 10px auto;
		.background-white {
			background-color: #fff;
      padding: 5px 10px;
			box-sizing: border-box;
      border-radius: 10px;
			.uni-forms-item__label {
				color: #333;
				font-size: 30rpx;
			}

			.text {
        margin: 10px 0;
				color: #999;

				text {
					color: #333;
				}
			}
		}
	}

	.hidden-title {
		background: #f5f5f5;
    padding: 5px 0;
    color: #999;
	}

	.bor-top {
		border-top: 20rpx solid #f5f5f5;
	}

	.form-content {
		margin-bottom: 107px;
	}

	.submit-group {
		background: #fff;
		padding: 20px;
	}
  .maintenance-step{
    width: 96%;
    margin: 0 auto;
    .step-block{
      width: 100%;
      display: flex;
      justify-content: space-between;
      margin: 10px 0;
    }
    .step{
      width: 8%;
      .step-no{
        text-align: left;
        line-height: 30px;
      }
    }
    .step-content{
      width: 92%;
      border-radius: 10px;
      .uni-view{
        word-break: break-all;
        padding: 5px
      }
      .content-item{
        padding: 5px;
        font-size: 15px;
        uni-text:first-child{
          color: #999;
        }
      }
    }
  }
</style>
